//
//  CADelBankCardView.m
//  LNH
//
//  Created by twentylx on 2018/2/8.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CADelBankCardView.h"

@implementation CADelBankCardView

/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
}

/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    self.backgroundColor = RGBCOLOR(241, 241, 241);
}

/**
 初始化视图
 */
- (void)lm_createViewForView {
    [self setNeedsUpdateConstraints];
    
    [self addSubview:self.bgView];
    [self.bgView addSubview:self.cardLabel];
    [self.bgView addSubview:self.delButton];
}

#pragma mark layout
- (void)updateConstraints {
    [super updateConstraints];
    
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self).offset(20);
        make.bottom.equalTo(self);
    }];
    
    [_cardLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgView).offset(20);
        make.top.equalTo(self.bgView).offset(20);
    }];
    
    [_delButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bgView).offset(-20);
        make.top.equalTo(self.cardLabel);
    }];
}

#pragma mark get & set
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [UIView new];
        _bgView.backgroundColor = [UIColor whiteColor];
    }
    return _bgView;
}

- (UILabel *)cardLabel {
    if (!_cardLabel) {
        _cardLabel = [UILabel new];
        _cardLabel.font = [UIFont systemFontOfSize:16];
    }
    return _cardLabel;
}

- (UIButton *)delButton {
    if (!_delButton) {
        _delButton = [UIButton new];
        [_delButton setTitle:@"解除绑定" forState:UIControlStateNormal];
        [_delButton setTitleColor:RGBCOLOR(211, 4, 4) forState:UIControlStateNormal];
        _delButton.titleLabel.font = [UIFont systemFontOfSize:16];
    }
    return _delButton;
}

@end
